//
//  WZGPayTypeSelectCell.m
//  weizhegou
//
//  Created by sujeking on 2020/3/28.
//  Copyright © 2020 Facebook. All rights reserved.
//

#import "WZGPayTypeSelectCell.h"
#import "TBCityIconFont.h"
@interface WZGPayTypeSelectCell()

@property (weak, nonatomic) IBOutlet UIImageView * typeimv;
@property (weak, nonatomic) IBOutlet UIImageView *checkimv;
@property (weak, nonatomic) IBOutlet UILabel *label;

@end


@implementation WZGPayTypeSelectCell

- (void)awakeFromNib {
  [super awakeFromNib];
  self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  [super setSelected:selected animated:animated];
  
  if (selected) {
    UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e684", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0xff0000"])];
    self.checkimv.image = img;
  } else {
    UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e647", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0xD8D8D8"])];
    self.checkimv.image = img;
    if (self.dict != nil) {
      BOOL enable = [[self.dict valueForKey:@"enable"] boolValue];
      if (!enable) {
        self.checkimv.image = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e602", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0xD8D8D8"])];
      }
    }
  }
  // Configure the view for the selected state
}

- (void)setDict:(NSDictionary *)dict {
  if (dict == nil) {
    return;
  }
  _dict = dict;
  
  NSString *labelstr = [dict valueForKey:@"label"];
  NSInteger ids = [[dict valueForKey:@"id"] integerValue];
  if( ids == 1 ){
    self.label.text = [NSString stringWithFormat:@"%@",labelstr];
  } else {
    self.label.text = labelstr;
  }
}

- (void)setMessage:(NSString *)message {
  _message = message;
  self.label.text = [NSString stringWithFormat:@"%@(%@))",self.label.text,message];
}

- (void)setWallet:(NSString *)wallet {
  _wallet = wallet;
  self.label.text = [NSString stringWithFormat:@"%@(余额:￥%.2f)", self.label.text,wallet.floatValue];
}

- (void)setPt:(NSString *)pt {
  _pt = pt;
  WZGPayTypeSelectType type = pt.intValue;
  switch (type) {
    case WZGPayTypeSelectType_Balance :{
      UIImage *img = [UIImage imageNamed:@"orderpay_balance"];
      self.typeimv.image = img;
    } break;
    case WZGPayTypeSelectType_AliPay :{
      UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e610", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0x3aa0e8"])];
      self.typeimv.image = img;
      
    } break;
    case WZGPayTypeSelectType_Wechat :{
      UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e643", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0x50ad29"])];
      self.typeimv.image = img;
    } break;
    case WZGPayTypeSelectType_WechatFriend :{
      UIImage *img = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e601", 25, [generalToolBox getColorWithHexadecimalColorStr:@"0x50ad29"])];
      self.typeimv.image = img;
    } break;
      
    default:
      break;
  }
}

@end
